<!DOCTYPE HTML>
<html>
<head>
<include file="Include:meta" />
<title>{$type_names}详情-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">{$type_name} > {$type_names}详情</div>
	</div>
	<div id="content">
		<div class="form-main">
			<div class="form-title">{$type_names}详情</div>
			<div class="form-item">
				<div width="10%" class="input-label">所属中心</div>
				<div class="input-item">
					{$business['center_name']}
				</div>
			</div>
			<div class="form-item">
				<div width="10%" class="input-label"><if condition="$business['type'] neq 5">名称<else />姓名</if></div>
				<div class="input-item">
					{$business['name']}
				</div>
			</div>
			<if condition="$business['type'] neq 5">
				<div class="form-item">
					<div width="10%" class="input-label">附件</div>
					<div class="input-item">
						<div class="input-append">
							<if condition="($business['type'] eq 4) or ($business['type'] eq 3)">
							{$business['file_name']}<a href="{$business['file_url']}" did="{$business['id']}" target="_blank" data-toggle="tooltip" data-placement="left" title="下载" class="ml5"><i  zid="{$business['id']}" class="glyphicon glyphicon-download-alt download"></i></a>
							<elseif condition="($business['type'] eq 5) or ($business['type'] eq 6) or ($business['type'] eq 7)"/>
							{$business['file_name']}<a href="{$business['file_url']}" did="{$business['id']}" target="_blank" data-toggle="tooltip" data-placement="left" title="下载" class="ml5"><i  zid="{$business['id']}" class="glyphicon glyphicon-download-alt"></i></a>
							<else />
							<if condition="$business['swfs'] eq 1"><a href="javascript:;" zid="{$business.id}" class="swf">{$business['file_name']}</a><elseif condition="$business['yp'] eq 1"/><a href="{$business['file_url']}" target="_blank" class="download">{$business['file_name']}</a><else/>{$business['file_name']}</if>
							</if>
						</div>
					</div>
				</div>
				<foreach name="screen" item="vo" key="k">
					<div class="form-item">
						<div class="input-label">{$vo['first_name']}</div>
						<div class="input-item">
							{$business['types'][$k]}
						</div>
					</div>
				</foreach>
				<div class="form-item">
					<div class="input-label">说明</div>
					<div class="input-item">
						{$business['remark']}
					</div>
				</div>
			<else />
				<foreach name="screen" item="vo" key="k">
					<div class="form-item">
						<div class="input-label">{$vo['first_name']}</div>
						<div class="input-item">
							{$business['types'][$k]}
						</div>
					</div>
				</foreach>
				<div class="form-item">
					<div width="10%" class="input-label">附件</div>
					<div class="input-item">
						<div class="input-append">
							<if condition="$business['file_url'] neq NULL">{$business['file_name']}<a href="{$business['file_url']}" did="{$business['id']}" target="_blank" data-toggle="tooltip" data-placement="left" title="下载" class="ml5"><i  zid="{$business['id']}" class="glyphicon glyphicon-download-alt"></i></a></if>
						</div>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">从业经验</div>
					<div class="input-item">
						{$business['remark']}
					</div>
				</div>
			</if>
			<if condition="$audit neq ''">
				<div class="form-sub-title">审核流程</div>
				<foreach name="audit_user" item="vo">
					<div class="form-item clearfix">
						<div class="item-float">
							<div class="input-label">{$vo['audit_name']}</div>
							<div class="input-item">
								<if condition="$vo['audit_date'] neq NULL">
									{$vo['audit_user']}({$vo['audit_date']|substr=0,10})<if condition="$vo['audit_comments'] neq NULL">:{$vo['audit_comments']}</if>
								<else/>
									<span class='red'>[未审核]{$vo['audit_user']}</span>
								</if>
							</div>
						</div>
					</div>
				</foreach>
				<div class="form-btn-item">
					<if condition="$business['status'] egt 0">
						<if condition="($shenhe eq 1)">
							<button status="{$business['status']}" mid="{$business['mid']}" uuid="{$login_id}" class="btn btn-audit" type="button">审核</button>
						</if>
						<if condition="($qishen eq 1)">
							<button status="{$business['status']}" mid="{$business['mid']}" class="btn btn-giveup" type="button">弃审</button>
						</if>
					</if>
				</div>
			</if>
		</div>
		<if condition="($business['type'] eq 4)">
		<div class="form-main">
			<div class="form-title">沟通记录
			<if condition="((get_permission('GY',NULL,3)) and ($business['add_uid'] eq $login_id)) or (get_permission('GY',NULL,2) and strstr($business['center_id'],$login_center_id)) or (get_permission('GY',NULL,1))">
			<a href="javascript:;" class="ml10 btn-add" data-toggle="tooltip" data-placement="right" title="添加"><i class="glyphicon glyphicon-plus"></i></a>
			</if>
			</div>
			<div class="form-table-item">
				<table class="table">
					<tbody>
						<tr class="form-table-header">
							<td width="10%">沟通日期</td>
							<td width="55%">沟通内容</td>
							<td width="15%">附件</td>
							<td width="10%">添加人(日期)</td>
							<if condition="((get_permission('GY',NULL,3)) and ($business['add_uid'] eq $login_id)) or (get_permission('GY',NULL,2) and strstr($business['center_id'],$login_center_id)) or (get_permission('GY',NULL,1))">
							<td width="10%">管理</td>
							</if>
						</tr>
						<if condition="$partner_list eq NULL">
						<tr>
							<td class="text-center" <if condition="((get_permission('GY',NULL,3)) and ($business['add_uid'] eq $login_id)) or (get_permission('GY',NULL,2) and strstr($business['center_id'],$login_center_id)) or (get_permission('GY',NULL,1))">colspan="5"<else />colspan="4"</if>>暂无相关数据</td>
						</tr>
						</if>
						<foreach name="partner_list" item="vo">
							<tr>
								<td>{$vo['p_date']}</td>
								<td>{$vo['content']}</td>
								<td><if condition="$vo['file_url'] neq NULL">{$vo['file_name']}<a href="{$vo['file_url']}" target="_blank" class="ml5" data-toggle="tooltip" data-placement="right" title="下载"><i class="glyphicon glyphicon-download-alt"></i></a></if></td>
								<td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
								<if condition="((get_permission('GY',NULL,3)) and ($business['add_uid'] eq $login_id)) or (get_permission('GY',NULL,2) and strstr($business['center_id'],$login_center_id)) or (get_permission('GY',NULL,1))">
									<td>
										<if condition="$key eq 0">
											<a href="javascript:;" class="btn-edit" mid="{$vo['id']}" data-toggle="tooltip" data-placement="left" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
											<a href="javascript:;" class="btn-delete ml5" mid="{$vo['id']}" action="partner_delete" data-toggle="tooltip" data-placement="left" title="删除"><i class="glyphicon glyphicon-trash"></i></a>
										</if>
									</td>
								</if>
							</tr>
						</foreach>
					</tbody>
				</table>
			</div>
		</div>
		</if>
		<if condition="($business['type'] eq 7)">
		<div class="form-main">
			<div class="form-title">沟通记录
			<if condition="((get_permission('IP',NULL,3)) and ($business['add_uid'] eq $login_id)) or (get_permission('IP',NULL,2) and strstr($business['center_id'],$login_center_id)) or (get_permission('IP',NULL,1))">
			<a href="javascript:;" class="ml10 btn-add" data-toggle="tooltip" data-placement="right" title="添加"><i class="glyphicon glyphicon-plus"></i></a>
			</if>
			</div>
			<div class="form-table-item">
				<table class="table">
					<tbody>
						<tr class="form-table-header">
							<td width="10%">沟通日期</td>
							<td width="55%">沟通内容</td>
							<td width="15%">附件</td>
							<td width="10%">添加人(日期)</td>
							<if condition="((get_permission('IP',NULL,3)) and ($business['add_uid'] eq $login_id)) or (get_permission('IP',NULL,2) and strstr($business['center_id'],$login_center_id)) or (get_permission('IP',NULL,1))">
							<td width="10%">管理</td>
							</if>
						</tr>
						<if condition="$partner_list eq NULL">
						<tr>
							<td class="text-center" <if condition="((get_permission('IP',NULL,3)) and ($business['add_uid'] eq $login_id)) or (get_permission('IP',NULL,2) and strstr($business['center_id'],$login_center_id)) or (get_permission('IP',NULL,1))">colspan="5"<else />colspan="4"</if>>暂无相关数据</td>
						</tr>
						</if>
						<foreach name="partner_list" item="vo">
							<tr>
								<td>{$vo['p_date']}</td>
								<td>{$vo['content']}</td>
								<td><if condition="$vo['file_url'] neq NULL">{$vo['file_name']}<a href="{$vo['file_url']}" target="_blank" class="ml5" data-toggle="tooltip" data-placement="right" title="下载"><i class="glyphicon glyphicon-download-alt"></i></a></if></td>
								<td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
								<if condition="((get_permission('IP',NULL,3)) and ($business['add_uid'] eq $login_id)) or (get_permission('IP',NULL,2) and strstr($business['center_id'],$login_center_id)) or (get_permission('IP',NULL,1))">
									<td>
										<if condition="$key eq 0">
											<a href="javascript:;" class="btn-edit" mid="{$vo['id']}" data-toggle="tooltip" data-placement="left" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
											<a href="javascript:;" class="btn-delete ml5" mid="{$vo['id']}" action="partner_delete" data-toggle="tooltip" data-placement="left" title="删除"><i class="glyphicon glyphicon-trash"></i></a>
										</if>
									</td>
								</if>
							</tr>
						</foreach>
					</tbody>
				</table>
			</div>
		</div>
		</if>
		<if condition="(($business['status'] eq 2) and ($audit neq 'sh')) and (($business['type'] eq 1) or ($business['type'] eq 2) or ($business['type'] eq 3) or ($business['type'] eq 4))">
		<div class="form-main">
			<div class="form-title">{$type_names}评论</div>
			<div>
				<foreach name="reply" item="vo" key="k">
					<div id="reply{$k+1}" class="reply-list">
						<div class="reply-pi">{$k+1}楼</div>
						<div class="reply-name">
							{$vo['add_user']}：
						</div>
						<div class="reply-comment">{$vo['content']}</div>
						<div class="reply-date">
							<if condition="$vo['reply_able'] eq 1">
							<a href="javascript:;" class="relpay mr5">回复</a>
							</if>
							<if condition="$vo['delete'] eq 1">
							<a href="javascript:;" class="delete red mr5" comment_id="{$vo['id']}">删除</a>
							</if>
							{$vo['add_date']}
						</div>
						<if condition="$vo['answer'] neq NULL">
							<div class="reply_content_box">
								<div class="title">回复</div>
								<div class="reply_content">
									<div class="reply-name">
										{$vo['answer']['add_user']}：
									</div>
									<div class="reply-comment">{$vo['answer']['content']}</div>
									<div class="reply-date">
										<if condition="$vo['answer']['delete'] eq 1">
											<a href="javascript:;" class="delete_reply red mr5" reply_id="{$vo['answer']['id']}">删除</a>
										</if>
										{$vo['answer']['add_date']}
									</div>
								</div>
							</div>
						</if>
						<div class="replay_blk hide">
							<strong>发表回复</strong><br />
							<textarea class="form-control replay-textarea w500 h100" autocomplete="off"></textarea>
							<br>
							<button type="button" reply_id="{$vo['id']}" class="btn reply_sub mt5">提交</button>
							<input type="button" class="btn btn-default reply_cancel mt5 ml5" value="取消">
						</div>
					</div>
				</foreach>
			</div>
			<div class="form-item">
				<div class="input-label">发表评论</div>
				<div class="input-item">
					<textarea class="form-control comment-textarea w500 h100" autocomplete="off"></textarea>
					<br>
					<button type="button" class="btn mt5 comment_btn">提交</button>
				</div>
			</div>
		</div>
		</if>
	</div>
	<if condition="$audit eq ''">
	<div class="form-btn-item"><button <if condition="$_SESSION['inde_more_url'] eq NULL">class="btn btn-default goback"<else/>class="btn btn-default goback1"</if> type="button">返回</button></div></if>
</div>
<!--对话框-->
<div class="modal fade" id="deleteModal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>确认提示框</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">您确定要删除该评论吗？</div>
			<div class="modal-footer">
				<button type="button" class="btn del">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<div class="modal fade" id="deleteModal2">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>确认提示框</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">您确定要删除该回复吗？</div>
			<div class="modal-footer">
				<button type="button" class="btn del">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--弹框-->
<div class="modal fade" id="edit-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4></h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>沟通日期</strong></td>
						<td>
							<input type="text" class="form-control Wdate w100 date" onclick="WdatePicker()" readonly autocomplete="off" />
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>沟通内容</strong></td>
						<td>
							<textarea class="form-control w400 textarea explain" autocomplete="off"></textarea>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong>附件</strong></td>
						<td>
							<div class="input-group w300 left">
						    	<input type="text" class="form-control file-name" placeholder="请上传附件" autocomplete="off">
					    		<span class="input-group-btn">
					        		<button class="btn file-submit" type="button">上传</button>
						    	</span>
						    </div>
						    <button class="btn file-delete ml5" type="button">删除</button>
						    <input type="hidden" class="file-url" autocomplete="off">
						    <span class="error-item">请上传附件</span>
							<span class="error-item">文件名必填</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	$(".goback1").click(function(){
		var $url = "{$_SESSION['inde_more_url']}";
		window.location.href = $url;
	});
	//删除项目过程文件
	$(".btn-delete").ajaxModal({"title_text":"确认提示框","body_text":"您确定要删除吗？","url":"__APP__/Index/library_ajax","data":{"id":"mid","action":"action"}});
	
	KindEditor.ready(function(K){
		//上传附件
		var editorFile = K.editor();
		$('.file-submit').on('click',function(){
			var parents = $(this).parents(".input-group");
			editorFile.loadPlugin('insertfile',function(){
				document.cookie="file_name=partner";
				document.cookie="file_type=ppt,pptx,pdf,doc,docx,jpg,jpeg,png,xls,xlsx,txt,rar,zip";
				editorFile.plugin.fileDialog({
					clickFn:function(url,title){
						parents.nextAll(".error-item").hide();
						parents.find(".file-name").val(title).prop("readonly",false);
						parents.nextAll(".file-url").val(url);
						parents.nextAll(".file-delete").show();
						editorFile.hideDialog();
					}
				});
			});
		});
	});
	
	//阅读
	$('.download').on("click",function(){
		var $zid = $(this).attr("zid");
		$.ajax({
			cache:false,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/library_ajax",
			data:{"id":$zid,"action":"download"}
		});
	});
	
	//统计下载量
	$(".download-num").on("click",function(){
		var $main_id = "{$business['id']}";
		$.ajax({
			cache:true,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/library_ajax",
			data:{"id":$main_id,"action":"download"}
		});
	});

	//发表评论
	$(".comment_btn").click(function(){
		var $textarea = $(this).prevAll(".comment-textarea").eq(0),
			$val = $textarea.val(),
			$main_id = "{$business['id']}";
		if($val=="" || /^\s+$/.test($val) || $val=="请输入评论内容"){
			$textarea.val("请输入评论内容").addClass("red");
		}else{
			$.ajax({
				cache:true,
				type:"POST",
				dataType:"json",
				url:"__APP__/Index/library_reply",
				data:{"action":"comment","main_id":$main_id,"content":$val},
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	
	//删除附件
	$(".file-delete").click(function(){
		$(this).hide();
		$(this).nextAll(".error-item").hide();
		$(this).nextAll(".file-url").val("");
		$(this).prevAll(".input-group").find(".file-name").val("").prop("readonly",true);
		$(this).parents("tr").find(".required-text2").next(".error-item").hide();
	});
	
	//添加
	$(".btn-add").on("click",function(){
		var modal = $("#edit-modal");
		modal.find(".modal-header h4").text("添加沟通记录");
		modal.find(".file-name").prop("readonly",true);
		modal.find(".file-delete").hide();
		modal.modal();
	});

	//编辑
	$(".btn-edit").on("click",function(){
		var mid = $(this).attr("mid"),
			modal = $("#edit-modal");
		modal.find(".modal-header h4").text("编辑沟通记录");
		modal.find(".btn-affirm").attr({"mid":mid});
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"action":'partner',"id":mid},
			url:"__APP__/Index/library_ajax",
			success:function(data){
				modal.find(".file-name").val(data.file_name);
				modal.find(".file-url").val(data.file_url);
				modal.find(".date").val(data.p_date);
				modal.find(".explain").val(data.content);
				modal.modal();
				if(data.file_url){
					modal.find(".file-name").prop("readonly",false);
					modal.find(".file-delete").show();
				}else{
					modal.find(".file-name").prop("readonly",true);
					modal.find(".file-delete").hide();
				}
			}
		});
	});

	//确定
	$("#edit-modal").find(".btn-affirm").on("click",function(){
		var tag = true,
			mid = $(this).attr("mid"),
			action,
			modal = $("#edit-modal");
		if(!mid){
			mid = "";
			action="partner_add";
		}else{
			action="partner_edit";
		}
		modal.find(".textarea").each(function(){
			var val = $(this).val();
			if(val==""){
				$(this).next(".error-item").show();
				tag = false;
			}
		});
		modal.find(".name,.date").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = false;
			}
		});
		modal.find(".file-name").each(function(){
			val = $(this).val();
			if((val=="" || /^\s+$/.test(val)) && !$(this).prop("readonly")){
				$(this).parents(".input-group").nextAll(".error-item").eq(1).show();
				tag = false;
			}
		});

		if(tag){
			var file_name = modal.find(".file-name").val(),
				file_url = modal.find(".file-url").val(),
				date = modal.find(".date").val(),
				m_id="{$business['id']}",
				explain = modal.find(".explain").val();
			modal.hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"action":action,"id":mid,"m_id":m_id,"file_name":file_name,"file_url":file_url,"p_date":date,"content":explain},
				url:"__APP__/Index/library_ajax",
				success:function(data){
					success_pop(data.status);
				}
			});
		}
	});
	
	//取消错误提示
	$("textarea").focus(function(){
		var $val = $(this).val();
		if($val=="" || /^\s+$/.test($val) || $val=="请输入回复内容"){
			$(this).val("").removeClass("red");
		}
	});
	$(".textarea").focus(function(){
		$(this).next(".error-item").hide();
	});
	$(".date").click(function(){
		$(this).next(".error-item").hide();
	});
	//删除评论
	$(".delete").click(function(){
		var comment_id = $(this).attr("comment_id");
		$("#deleteModal").find(".del").attr({"comment_id":comment_id}).end().modal();
	});
	
	$("#deleteModal").find(".del").click(function(){
		var comment_id = $(this).attr("comment_id");
		$("#deleteModal").hide();
		$.ajax({
			type:"POST",
			asnyc:true,
			dataType:"json",
			data:{"action":"delete_comment","id":comment_id},
			url:"__APP__/Index/library_reply",
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
	
	//发表回复
	$(".relpay").click(function(){
		$(this).parents(".reply-list").find(".replay_blk").slideDown();
	});
	
	$(".reply_sub").click(function(){
		var $textarea = $(this).prevAll(".replay-textarea").eq(0),
			$val = $textarea.val(),
			$main_id = "{$business['id']}",
			$reply_id = $(this).attr("reply_id");
		if($val=="" || /^\s+$/.test($val) || $val=="请输入回复内容"){
			$textarea.val("请输入回复内容").addClass("red");
		}else{
			$.ajax({
				cache:true,
				type:"POST",
				dataType:"json",
				url:"__APP__/Index/library_reply",
				data:{"action":"reply","main_id":$main_id,"reply_id":$reply_id,"content":$val},
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	
	//回复取消
	$(".reply_cancel").click(function(){
		$(this).parents(".replay_blk").slideUp();
		$(this).prevAll(".replay-textarea").eq(0).val("").removeClass("red");
	});
	
	//删除回复
	$(document).on("click",".delete_reply",function(){
		var reply_id = $(this).attr("reply_id");
		$("#deleteModal2").find(".del").attr({"reply_id":reply_id}).end().modal();
		$("#deleteModal2").modal();
	});
	
	$("#deleteModal2 .del").click(function(){
		var reply_id = $(this).attr("reply_id");
		$("#deleteModal2").hide();
		$.ajax({
			type:"POST",
			asnyc:true,
			dataType:"json",
			data:{"action":"delete_reply","id":reply_id},
			url:"__APP__/Index/library_reply",
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
	
	//swf展示
	$(".swf").click(function(){
		var id = $(this).attr("zid");
		window.open('__APP__/Index/swf_list/id/'+id+'/db/db_library_main', '', "width="+ (screen.availWidth - 10) +",height="+ (screen.availHeight-10) +",directories=no,location=no,menubar=no,scrollbars=no,resizeable=no,status=no,toolbar=no");
	});
	
	//审核
	$('.btn-audit').on("click",function(){
		var mid = $(this).attr("mid"),
			uuid = $(this).attr("uuid"),
			status = parseInt($(this).attr("status"))+1,
			audit_message = $("[name='audit_message']").val(),
			modal = $("#edit-modal");
		modal.hide();
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"mid":mid,"audit_message":audit_message,"uuid":uuid,"status":status,"type":"6"},
			url:"__APP__/Index/audit_list_ajax",
			success:function(data){
				success_pop(data.status,data.msg);
			}
		});
	});
	
	//弃审
	$('.btn-giveup').on("click",function(){
		var status = $(this).attr('status'),
			mid = $(this).attr("mid");
		$.ajax({
			cache:true,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/audit_list_ajax",
			data:{"mid":mid,"status":status},
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
});
</script>
</body>
</html>